<template>
    <view class="pages" :style="{ paddingTop: statusBarHeight + 'px' }">
        <slot></slot>
        <custom-tabbar :current="current" v-if="tab" />
    </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import CustomTabbar from '@/components/custom-tabbar.vue'
const statusBarHeight = ref(0)  // 添加状态栏高度变量

const props = defineProps({
    current: {
        type: Number,
        default: 0
    },
    tab: {
        type: Boolean,
        default: true
    }
})

// 初始化 scroll-view 高度
const initScrollHeight = () => {
    const systemInfo = uni.getSystemInfoSync()
    // #ifdef APP-PLUS
    statusBarHeight.value = systemInfo.statusBarHeight || 0
    // #endif

    // #ifndef APP-PLUS
    statusBarHeight.value = 20
    // #endif
}

// 页面加载时初始化
onMounted(async () => {
    if (props.tab) {
        initScrollHeight()
    }
})
</script>

<style lang="scss" scoped>
.pages {
    padding: 32rpx;
    background-color: #f5f7fa;
}
</style>